package com.hevs.samplewebapp.server.service;

import com.hevs.samplewebapp.server.dao.DAOFactory;
import com.hevs.samplewebapp.server.dao.DAOImplFactory;
import com.hevs.samplewebapp.server.dao.InternalMessageDAO;
import com.hevs.samplewebapp.server.dao.MedicalRecordDAO;
import com.hevs.samplewebapp.server.dao.UserDAO;

/**
 * Service superclass for unique DAO access
 * 
 * @author Arnaud Durand
 * @date 14.03.12
 */
public abstract class Service {

private DAOFactory daoFactoryInstance;
	
	/**
	 * Default constructor with datastore DAO
	 */
	public Service() {
		this.daoFactoryInstance=DAOImplFactory.getInstance();
	}
	
	/**
	 * Constructor with specified DAOFactory
	 * 
	 * @param daoFactoryInstance
	 *            factory which is called for DAO instantiation
	 */
	public Service(DAOFactory daoFactoryInstance){
		this.daoFactoryInstance=daoFactoryInstance;
	}
	
	/**
	 * Get the DAO factory used by the service
	 * 
	 * @return the DAO factory
	 */
	public DAOFactory getDaoFactoryInstance() {
		return daoFactoryInstance;
	}
	
	/**
	 * Set the DAO factory used by the service
	 * 
	 * @param daoFactoryInstance
	 */
	public void setDaoFactoryInstance(DAOFactory daoFactoryInstance) {
		this.daoFactoryInstance = daoFactoryInstance;
	}
	
	/**
	 * Get the medical record DAO used by the service
	 * 
	 * @return medical record DAO
	 */
	public MedicalRecordDAO getMedicalRecordDAO(){
		return daoFactoryInstance.getMedicalRecordDAO();
	}
	
	/**
	 * Get the internal message DAO used by the service
	 * 
	 * @return internal message DAO
	 */
	public InternalMessageDAO getInternalMessageDAO(){
		return daoFactoryInstance.getInternalMessageDAO();
	}
	
	/**
	 * Get the user DAO used by the service
	 * 
	 * @return user DAO
	 */
	public UserDAO getUserDAO(){
		return daoFactoryInstance.getUserDAO();
	}
	
	
}
